package com.nisco.datastruction;

import com.sun.source.tree.BinaryTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.TreeVisitor;
import lombok.Data;

import java.util.Stack;

public class StackTest
{
    @Data
    static class BinaryNode<T, S> {
        private T depth;
        private S direct;

        public BinaryNode(T depth, S direct)
        {
            this.depth = depth;
            this.direct = direct;
        }

        public String toString()
        {
            return "()";
        }
    }
    public static void main(String[] args)
    {
        final int n = 4;
        int[] a = new int[] {1, 3, 4, 7};
        int k = 15;

        System.out.println(new StackTest().dfs(a, k));
    }

    boolean dfs(final int[] a, final int k)
    {
        final int len = a.length;
        Stack<BinaryNode<Integer, Integer>> stack = new Stack<>();
        int sum = 0;
        BinaryNode<Integer, Integer> root = new BinaryNode<>(0, 0);
        do
        {
            System.out.println(root.getDepth() + "," + root.getDirect());
            if (root.getDepth() < len)
            {
                stack.push(root);
                root = new BinaryNode<>(root.getDepth() + 1, 0);
            }
            else
            {
                if (stack.empty())
                {
                    break;
                }
                BinaryNode<Integer, Integer> pop = stack.pop();
                root = new BinaryNode<>(pop.getDepth() + 1, 1);
            }
        } while (!stack.empty());

        return false;
    }


}
